package com.guigu.dealservice.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.guigu.dealservice.dto.Equipment;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author janecraft
 * @since 2025-10-17
 */
@TableName("equipment_reservation")
public class EquipmentReservation implements Serializable {

    private static final long serialVersionUID = 1L;

    public Equipment getEquipment() {
        return equipment;
    }

    public void setEquipment(Equipment equipment) {
        this.equipment = equipment;
    }

    /**
     * 预定记录唯一标识
     */
    @TableId(value = "reservation_id", type = IdType.AUTO)
    private Long reservationId;

    /**
     * 关联用户表user_id（发起预定的买家）
     */
    private Long userId;

    /**
     * 关联设备表equipment_id（目标预定设备）
     */
    private Long equipmentId;

    /**
     * 预定押金金额（用户支付的预定保证金，默认不低于设备原价的5%）
     */
    private BigDecimal reservationDeposit;

    /**
     * 预定有效期（单位：天，如3天内需完成下单，过期自动取消）
     */
    private Integer reservationPeriod;

    /**
     * 预定状态（0-待支付押金，1-已支付押金，2-已转订单，3-已取消，4-已过期）
     */
    private Integer reservationStatus;

    /**
     * 押金支付时间（reservation_status=1时记录）
     */
    private LocalDateTime depositPayTime;

    /**
     * 关联订单表order_id（reservation_status=2时必填，记录转为的正式订单）
     */
    private Long orderId;

    /**
     * 取消原因（reservation_status=3时填写，如"用户放弃购买"）
     */
    private String cancelReason;

    /**
     * 取消时间（reservation_status=3时记录）
     */
    private LocalDateTime cancelTime;

    /**
     * 预定过期时间（根据create_time+reservation_period计算，过期自动更新状态为4）
     */
    private LocalDateTime expireTime;

    /**
     * 记录创建时间（用户发起预定的时间）
     */
    private LocalDateTime createTime;

    /**
     * 记录更新时间
     */
    private LocalDateTime updateTime;

    /**
     * 卖家id
     */
    @TableField(exist = false)
    private Long sellerId;

    /**
     * 订单总金额（单位：元，设备成交价格）
     */
    @TableField(exist = false)
    private BigDecimal orderAmount;

    /**
     * 定金金额（订单总金额的30%，用于锁定设备）
     */
    @TableField(exist = false)
    private BigDecimal depositAmount;

    @TableField(exist = false)
    private Order order;

    @TableField(exist = false)
    private Equipment equipment;




    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    public Long getReservationId() {
        return reservationId;
    }

    public void setReservationId(Long reservationId) {
        this.reservationId = reservationId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Long getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(Long equipmentId) {
        this.equipmentId = equipmentId;
    }

    public BigDecimal getReservationDeposit() {
        return reservationDeposit;
    }

    public void setReservationDeposit(BigDecimal reservationDeposit) {
        this.reservationDeposit = reservationDeposit;
    }

    public Integer getReservationPeriod() {
        return reservationPeriod;
    }

    public void setReservationPeriod(Integer reservationPeriod) {
        this.reservationPeriod = reservationPeriod;
    }

    public Integer getReservationStatus() {
        return reservationStatus;
    }

    public void setReservationStatus(Integer reservationStatus) {
        this.reservationStatus = reservationStatus;
    }

    public LocalDateTime getDepositPayTime() {
        return depositPayTime;
    }

    public void setDepositPayTime(LocalDateTime depositPayTime) {
        this.depositPayTime = depositPayTime;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    public LocalDateTime getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(LocalDateTime cancelTime) {
        this.cancelTime = cancelTime;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    public Long getSellerId() {
        return sellerId;
    }

    public void setSellerId(Long sellerId) {
        this.sellerId = sellerId;
    }

    public BigDecimal getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(BigDecimal orderAmount) {
        this.orderAmount = orderAmount;
    }

    public BigDecimal getDepositAmount() {
        return depositAmount;
    }

    public void setDepositAmount(BigDecimal depositAmount) {
        this.depositAmount = depositAmount;
    }
    @Override
    public String toString() {
        return "EquipmentReservation{" +
        "reservationId = " + reservationId +
        ", userId = " + userId +
        ", equipmentId = " + equipmentId +
        ", reservationDeposit = " + reservationDeposit +
        ", reservationPeriod = " + reservationPeriod +
        ", reservationStatus = " + reservationStatus +
        ", depositPayTime = " + depositPayTime +
        ", orderId = " + orderId +
        ", cancelReason = " + cancelReason +
        ", cancelTime = " + cancelTime +
        ", expireTime = " + expireTime +
        ", createTime = " + createTime +
        ", updateTime = " + updateTime +
        ", sellerId = " + sellerId +
        ", orderAmount = " + orderAmount +
        ", depositAmount = " + depositAmount +
        "}";
    }
}
